package com.wjj.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.wjj.entity.Groups;
import com.wjj.entity.Pay;
import com.wjj.entity.User;

public interface PayDao {
	//列表的查询
	List<Pay> selectPay(Pay pay);
	//找到所有公司
	@Select("select * from t_groups where parent_id = 0")
	List<Groups> getCompany();
	//找到所有的事业部
	@Select("select * from t_groups where parent_id = #{pid}")
	List<Groups> getGroups(Integer pid);
	//添加发新单
	void addPay(Pay pay);
	//添加发薪人
	void addUser(User user);
	//查找发信人是否存在
	@Select("select * from t_user where name = #{name}")
	User selectUser(User user);
	//添加中间表
	@Insert("INSERT INTO `1904`.`t_p_u` (`id`, `p_id`, `u_id`) VALUES (null, #{id}, #{bid})")
	void addPU(@Param("id")Integer id,@Param("bid") Integer id2);
	//回显对象
	@Select("select * from t_pay where id = #{id}")
	Pay getPay(Integer id);
	//查找所有的发薪人****
	@Select("select * from t_user a LEFT JOIN t_p_u b on a.id = b.u_id where b.p_id = #{id}")
	List<User> listtUser(Integer id);
	//修改发薪单
	@Update("UPDATE `t_pay` SET   `name`=#{name}, `company_id`=#{company.id}, `business_id`=#{business.id}, `dept_id`=#{dept.id}, `account`=#{account}, `bills`=#{bills}, `createtime`= #{createtime} WHERE (`id`=#{id})")
	void updatePay(Pay pay);
	//删除中间表
	@Delete("DELETE FROM `t_p_u` WHERE (`p_id`=#{id})")
	int delPU(Pay pay);

}
